<?php 
	require_once __DIR__."/../Models/series.php";
	$series_model = new Models\Series($app);
	$series = $app['controllers_factory'];
	

	$series->get('/', function() use ($app, $series_model){
		$res = $series_model->getAll();
		return json_encode($res);
	});

	$series->post('/', function(Request $request) use ($app, $series_model){
		$data = array(
			"series_type"=>0, 
			"series_name"=>"name", 
			"series_season"=>1, 
			"series_count"=>1, 
			"series_link"=>'', 
			"series_date"=>''
		);
		echo json_encode( $data );
		$res = $series_model->insert($data);
		return json_encode($res);
	});


	$series->get('/{id}' , function($id) use($app, $series_model){
		$res = $series_model->getOne((int) $id);
		return json_encode($res);
	});

	$series->put('/{id}' , function($id, Request $request) use($app, $series_model){
		$res = $series_model->update((int) $id);
		return json_encode($res);
	});
	$series->delete('/{id}' , function($id) use($app, $series_model){
		$res = $series_model->delete((int) $id);
		return json_encode($res);
	});

	return $series;

?>